{layout name="admin/layout" /}
<style>
    .form-horizontal .form-group{
        margin-right:0;
        margin-left:0
    }
</style>
<div class="col-xs-12">
    <div class="page-header">
        <h1>{:v('headtitle')}</h1>
    </div>
    {if condition="has_menu($menu,'User/add')"}
    <button class="btn btn-success store" data-url="{:url('add')}" style="margin-bottom: 15px">新增用户</button>
    {/if}
    <form class="form-inline" style="margin-bottom: 15px" action="{:url('index')}" method="get">
        <select class="form-control" name="type" style="width: 100px">
            {if condition="$Think.get.type eq 2"}
            <option value="2">套装</option>
            {elseif condition="$Think.get.type eq 1" /}
            <option value="1">免费领取</option>
            {/if}
            <option value="2">套装</option>
            <option value="1">免费领取</option>
        </select>
        <select class="form-control" name="key" style="width: 100px">
            {if condition="$Think.get.key eq 'p_name'"}
            <option value="p_name">产品名</option>
            {elseif condition="$Think.get.key eq 'u_nickname'" /}
            <option value="u_nickname">用户昵称</option>
            {elseif condition="$Think.get.key eq 'i_phone'" /}
            <option value="i_phone">收件人手机号</option>
            {/if}
            <option value="p_name">产品名</option>
            <option value="u_nickname">用户昵称</option>
            <option value="i_phone">收件人手机号</option>
        </select>
        <input type="text" name="value" class="input" value="{$Think.get.value}">
        <button class="btn btn-sm btn-success" type="submit">&nbsp;搜索&nbsp;</button>
    </form>

    <div class="table-responsive">
        <table id="sample-table-1" class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                <th class="center">
                    <label>
                        <input type="checkbox" class="ace"/>
                        <span class="lbl"></span>
                    </label>
                </th>
                <th>id</th>
                <th>产品名</th>
                <th>用户昵称</th>
                <th>包装</th>
                <th>产品类型</th>
                <th>邮费</th>
                <th>配送费</th>
                <th>使用积分</th>
                <th>支付金额</th>
                <th>支付状态</th>
                <th>发货状态</th>
                <th>推广人</th>
                <th>经销商</th>
                <th>添加时间</th>
                <th>更新时间</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody>
            {volist name='list' id='v'}
            <tr>
                <td class="center">
                    <label>
                        <input type="checkbox" class="ace"/>
                        <span class="lbl"></span>
                    </label>
                </td>
                <td>{$v.id}</td>
                <td>{$v.p_name}</td>
                <td>{$v.u_nickname}</td>
                <td>{eq name='v.i_packing' value='1'}需要/¥3{else /}不需要{/eq}</td>
                <td>{eq name='v.i_type' value='1'}免费领取{else /}套装{/eq}</td>
                <td>{$v.i_postage}</td>
                <td>{$v.i_postarea}</td>
                <td>{$v.i_uintegral}</td>
                <td>{$v.i_totprice}</td>
                <td>{eq name='v.i_status' value='1'}已支付{else /}未支付{/eq}</td>
                <td>{switch name='v.i_confirm'}{case value='0'}未发货{/case}{case value='1'}已发货{/case}{case value='2'}已收货{/case}{/switch}</td>
                <td>{$v.p_id}</td>
                <td>{$v.dealer_id}</td>
                <td>{$v.create_time|date='Y-m-d H:i:s',###}</td>
                <td>{$v.update_time|date='Y-m-d H:i:s',###}</td>
                <td>
                    <div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
                        <a class="btn btn-xs btn-info" data-url="{:url('editaddress',['id'=>$v.id])}" onclick="edit_address(this,'{$v.i_uname}','{$v.i_phone}','{$v.i_detail}');">查看地址</a>

                        {if condition="has_menu($menu,'Indent/detail')"}
                            <a href="{:url('Indent/detail',['id'=>$v.id])}" class="btn btn-xs btn-info">详情</a>
                        {/if}
                        {if condition="has_menu($menu,'User/edit')"}
                        <button class="btn btn-xs btn-info store" data-url="{:url('edit',array('id'=>$v['id']))}">
                            <i class="icon-edit bigger-120"></i>
                        </button>
                        {/if}
                    </div>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <div style="text-align: center">
            {$page}
        </div>
    </div><!-- /.table-responsive -->
</div><!-- /span -->
{js href="https://cdn.bootcss.com/jquery/2.2.0/jquery.min.js" /}
{js href="__ROOT__/template/admin/assets/js/bootstrap.min.js" /}
{js href="__ROOT__/template/admin/assets/js/bootbox.min.js" /}
<script>
    function edit_address(th,name,phone,detail) {
        var content =   '收件人姓名<input class="bootbox-input form-control name" type="text" value="' + name + '">'+
                        '收件人手机<input class="bootbox-input form-control phone" type="text" value="' + phone + '">'+
                        '收件人详细地址<input class="bootbox-input form-control detail" type="text" value="' + detail + '">';
        bootbox.dialog({
            title: '友情提示：',
            message: content,
            buttons: {
                "success" : {
                    "label" : "修改",
                    "className" : "btn-success",
                    "callback": function() {
                        var url     = $(th).attr('data-url'),
                            name    = $('.name').val(),
                            phone   = $('.phone').val(),
                            detail  = $('.detail').val();
                        $.get(url, {i_uname:name,i_phone:phone,i_detail:detail}, function (ret) {
                            showMsg(ret.msg,ret.code);
                            setTimeout(function () {
                                window.location.reload();
                            },1000)
                        })
                    }
                },
                "close" : {
                    "label" : "取消",
                    "className" : "btn"
                }
            }
        });
    }
</script>